import java.util.Arrays;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextInt();
        }
        Arrays.sort(nums);
        int minDev = 0x3f3f3f3f;
        for (int i = 1; i < n; i++) {
            minDev = Math.min(minDev, nums[i]-nums[i-1]);
        }
        System.out.println(minDev);
    }
}
